package com.kt.thread.demo;

import java.util.concurrent.Callable;

/**
 * Created by tangwy on 2016/3/16.
 */
public class CreateThread {
    class MyThread extends Thread {
        private String threadName;
        public MyThread(String threadName) {
            this.threadName=threadName;
        }

        @Override
        public void run() {
            Thread currentThread=Thread.currentThread();
            currentThread.setName(threadName);
            System.out.println("自定义的线程类,线程名称:" + currentThread.getName());
        }
    }


    class MyRunnable implements Runnable{
        private String threadName;
        public MyRunnable(String threadName){
            this.threadName=threadName;
        }
        @Override
        public void run() {
            Thread currentThread=Thread.currentThread();
            currentThread.setName(threadName);
            System.out.println("实现Runnable接口创建的线程类,线程名称:" + currentThread.getName());
        }
    }

    class MyCallable implements Callable<Integer>{

        @Override
        public Integer call() throws Exception {
            System.out.println("Callable接口的call方法");
            return 0;
        }
    }
}

